package com.xc.stock.utils.fastjson;

import java.io.IOException;
import java.util.Date;

import com.ag.utils.DateUtils;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;

/**
 * 
 * title: DateJsonSerializer.java 
 *
 * @author rplees
 * @email rplees.i.ly@gmail.com
 * @version 1.0  
 * @created Jun 23, 2021 2:53:00 PM
 */
public class DateJsonSerializer extends JsonSerializer<Date> {

    @Override
    public void serialize(Date date, JsonGenerator jsonGenerator,
            SerializerProvider serializerProvider) throws IOException {
		if (null == date) {
			jsonGenerator.writeNull();
		} else {
			jsonGenerator.writeString(DateUtils.format(DateUtils.YYYY_MM_DD_HH_MM_SS, date));
		}
    }

}
